<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>

<script src="layui/layui.js"></script>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>商品小分类添加</legend>
</fieldset>

<form class="layui-form" action="/goodsCategory/addGoods" style="margin-top:200px;margin-left: 300px">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">小分类</label>
            <div class="layui-input-inline">
                <input type="text" id="categoryName" name="categoryName" lay-verify="required" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">大分类</label>
        <div class="layui-input-block">
            <div class="layui-input-inline">
                <select id="classId" name="classId" lay-filter="aihao">
                    <option value="">--选择--</option>
                    <option value="1">大家电</option>
                    <option value="2">电子产品</option>
                    <option value="3">鞋帽</option>
                    <option value="4">服饰</option>
                    <option value="5">汽车</option>
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script>

    layui.use(['upload', 'element', 'layer'], function () {
        var $ = layui.jquery
            , upload = layui.upload
            , element = layui.element
            , layer = layui.layer;
    });
    //Demo
    layui.use('form', function () {
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function (data) {
            layer.msg(JSON.stringify(data.field));//把表单中数据转成Json并输出
            //可以写一些验证
            return true;//true表示执行action对应的地址
        });
    });
</script>
</html>